package com.wjb.xietong.W3;

import com.wjb.xietong.Volley.RequestQueue;
import com.wjb.xietong.Volley.VolleyError;
import com.wjb.xietong.Volley.toolbox.ImageLoader;
import com.wjb.xietong.component.AppGlobal;

public class ImageLoaderRequest extends ImageLoader {

	public ImageLoaderRequest(RequestQueue queue, ImageCache imageCache) {
		super(queue, imageCache);
	}

	@Override
	public ImageContainer get(String requestUrl, ImageListener listener) {
		return super.get(requestUrl, new ImageLoaderRequestListener(listener));
	}

	public class ImageLoaderRequestListener implements ImageListener {

		private ImageListener mListener = null;

		public ImageLoaderRequestListener(ImageListener listener) {
			mListener = listener;
		}

		@Override
		public void onErrorResponse(VolleyError error) {
			if (null != mListener) {
				mListener.onErrorResponse(error);
			}
		}

		@Override
		public void onResponse(ImageContainer response, boolean isImmediate) {
			if (null != response.getBitmap()) {
//				ImageTools.saveBitmapImage(AppGlobal.getInstance().getAppPath()
//						+ "/", "", "", response.getBitmap());
			}

			if (null != mListener) {
				mListener.onResponse(response, isImmediate);
			}
		}

	}

}
